package org.ourgrid.worker.business.requester;

import java.util.ArrayList;
import java.util.List;

import org.ourgrid.common.internal.IResponseTO;
import org.ourgrid.common.internal.response.LoggerResponseTO;
import org.ourgrid.worker.business.dao.WorkerDAOFactory;
import org.ourgrid.worker.business.messages.ExecutionControllerMessages;
import org.ourgrid.worker.request.ReadyForAllocationRequestTO;

public class ReadyForAllocationRequester extends AbstractWorkerExecutionClientRequester<ReadyForAllocationRequestTO> {

	public List<IResponseTO> execute(ReadyForAllocationRequestTO request) {
		List<IResponseTO> responses = new ArrayList<IResponseTO>();
		
		responses.add(new LoggerResponseTO(ExecutionControllerMessages.getPrepareAllocationActionIsCompletedMessage(), 
				LoggerResponseTO.DEBUG));
		WorkerDAOFactory.getInstance().getWorkerStatusDAO().setPreparingAllocationState(false);
		
		statusChanged(responses, request.isWorkerDeployed());	
		
		return responses;
	}

}
